package com.xiaowu.datajpa.controller;

import com.xiaowu.datajpa.entity.Student;
import com.xiaowu.datajpa.service.StudentSercvice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Controller
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentSercvice studentSercvice;
    @GetMapping("/list")
    public String getList(Model model){
        List<Student> students = studentSercvice.findAll();
        model.addAttribute("list",students);
        return "/student/list2";
    }
}
